using System.Collections.Generic;
using Common;
using CSC440TeamOne.CSC440BusinessService.Interface.Services;
using Microsoft.Practices.CompositeWeb;
using Microsoft.Practices.Unity.Utility;
using System;

namespace CSC440TeamOne.Admin
{
    /// <summary>
    /// Name - AdminController.cs
    /// Description - Encapsulates all client requests from the Admin module
    /// Programmer - CSC440 Team One
    /// Date coded - 11/27/2011
    /// Arguments - IBusinessService
    /// Variables - None
    /// Files accessed by this code artifact - None
    /// Files changed by this code artifact - None
    /// I/O - None
    /// Error Handling - None
    /// Modifications -
    ///     1.0 - Initial coding
    /// Known Faults -
    ///     1.0 - None known
    /// </summary>
    public class AdminController : IAdminController
    {
        private IBusinessService _BusinessService;

        /// <summary>
        /// Initializes a new instance of the <see cref="AdminController"/> class.
        /// </summary>
        /// <param name="businessService">The business service.</param>
        public AdminController([ServiceDependency]IBusinessService businessService)
        {
            Guard.ArgumentNotNull(businessService, "businessService");

            _BusinessService = businessService;
        }

        /// <summary>
        /// Loads the tolerance config items.
        /// </summary>
        /// <returns></returns>
        public ToleranceConfigListViewModel LoadToleranceConfigItems()
        {
            return _BusinessService.LoadToleranceConfigItems();
        }

        /// <summary>
        /// Loads the health parameter by ID.
        /// </summary>
        /// <param name="healthParameterID">The health parameter ID.</param>
        /// <returns></returns>
        public ToleranceConfigDetailsViewModel LoadHealthParameterByID(int healthParameterID)
        {
            return _BusinessService.LoadHealthParameterByID(healthParameterID);
        }

        /// <summary>
        /// Saves the health parameter config.
        /// </summary>
        /// <param name="model">The model.</param>
        public void SaveHealthParameterConfig(ToleranceConfigDetailsViewModel model)
        {
            _BusinessService.SaveHealthParameterConfig(model);
        }

        /// <summary>
        /// Loads the SubmittedRecipesModel
        /// </summary>
        /// <returns></returns>
        public SubmittedRecipesModel LoadSubmittedRecipesModel()
        {
            return _BusinessService.LoadSubmittedRecipesModel();
        }

        /// <summary>
        /// Loads the VerifyRecipeModel
        /// </summary>
        /// <param name="id">The RecipeID</param>
        /// <returns>The RecipeID</returns>
        public VerifyRecipeModel LoadVerifyRecipeModel(int id)
        {
            return _BusinessService.LoadVerifyRecipeModel(id);
        }

        /// <summary>
        /// Returns full question list
        /// </summary>
        /// <returns></returns>
        public List<Question> LoadAllQuestions()
        {
            return _BusinessService.LoadAllQuestions();
        }

        /// <summary>
        /// Saves the updated help text to the database by passing it to the business service
        /// </summary>
        /// <param name="questionID"></param>
        /// <param name="helpText"></param>
        public void saveHelpText(int questionID, HelpText helpText)
        {
            _BusinessService.saveHelpText(questionID, helpText);
        }

        /// <summary>
        /// Gets the index of the user manual model by current.
        /// </summary>
        /// <param name="currentIndex">Index of the current.</param>
        /// <returns></returns>
        public UserManualModel GetUserManualModelByCurrentIndex(int currentIndex)
        {
            return _BusinessService.GetUserManualModelByCurrentIndex(currentIndex);
        }

        /// <summary>
        /// Saves the user manual model.
        /// </summary>
        /// <param name="model">The model.</param>
        public void SaveUserManualModel(UserManualModel model)
        {
            _BusinessService.SaveUserManualModel(model);
        }

        /// <summary>
        /// Adds the content of the user manual.
        /// </summary>
        /// <param name="model">The model.</param>
        public void AddUserManualContent(UserManualModel model)
        {
            _BusinessService.AddUserManualContent(model);
        }

        /// <summary>
        /// Adds the user manual section.
        /// </summary>
        /// <param name="model">The model.</param>
        public void AddUserManualSection(UserManualModel model)
        {
            _BusinessService.AddUserManualSection(model);
        }


        public SendMessageModel getSendMessageModel()
        {
            User user = new User();
            user.FirstName = "guid";
            user.UserId = new Guid("000");
            user.EmailAddress = Guid.NewGuid().ToString();
            SendMessageModel model = new SendMessageModel();
            model.users = new[] { user };
            return model;
        }
    }
}
